if (typeof TFacebook == 'undefined') {
	TFacebook = {};
}else{
	throw new Error("TFacebook namespace is taken")
}

TFacebook.APP_ID = ""; // Enter facebook app ID
TFacebook.loggedIn = false;

TFacebook.init = function(){
	FB.init({
		appId  : TFacebook.APP_ID, // the app ID you get when you register your app in http://www.facebook.com/developers/
		status : true, // check login status
		cookie : true, // enable cookies to allow the server to access the session
    });
}

TFacebook.login = function(){
	TFacebook.init();
	
	FB.login(function(response) {
		// response.authResponse is wrong, need to change this
		if (response.authResponse) {
			TFacebook.loggedIn = true;
		} else {
			// Else, login failed
		}
	}, {perms:'email,read_stream,publish_stream'});	
}

TFacebook.postStatusUpdate = function(body){
	FB.api('/me/feed', 'post', { message: body }, function(response) {
		if (!response || response.error) {
			alert(response.error.message);
		} else {
			alert("Successfully posted status update");		
		}
	});
}


/* 
//!Important:
Include this in html body

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>




//!Some random facebook javascript api code:

	FB.init({
      appId  : FB_APP_ID, // the app ID you get when you register your app in http://www.facebook.com/developers/
      status : true, // check login status
      cookie : true, // enable cookies to allow the server to access the session
      xfbml  : true  // parse XFBML
    });
	FB.getLoginStatus(function(response) {
		console.log(response);
		if(response.status == "connected"){
			accessToken = response.session.access_token;
		}else{
			console.log("NOT LOGGED IN");
		}
	});
	FB.api('/me', function(response) {
  		console.log(response);
		if(response.id){
			if(facebook_person == null || !facebook_person.facebook_id){
				createFacebookPerson(response.id, response.email);
			}
		}
	});
	FB.api('/me/feed', function(response) {
	    console.log(response);
	});
	FB.Canvas.setAutoResize();
*/
